/*

 * Copyright (C) 2021 Huawei Device Co., Ltd.

 * Licensed under the Apache License, Version 2.0 (the "License");

 * you may not use this file except in compliance with the License.

 * You may obtain a copy of the License at

 *

 *     http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */
 package com.aries.ui.util;

 import java.util.HashMap;

 /**
  * 颜色状态列表实例.
  */
 public class ColorStateListBean {
     private int state;
     private int color;


     private HashMap<Integer, Integer> colorMap;

     /**
      * 颜色状态列表实例.
      */
     public ColorStateListBean() {
         colorMap = new HashMap<>();
     }

     /**
      * 获取颜色.
      *
      * @param state state
      * @return color
      */
     public int getColor(int state) {
         if (colorMap.size() > 0 && colorMap.containsKey(state)) {
             return colorMap.get(state);
         }
         if (colorMap.size() > 0 && state == 2048 && colorMap.containsKey(0)) {
             return colorMap.get(0);
         }
         return 0;
     }

     /**
      * 设置状态和颜色.
      *
      * @param state 状态
      * @param color 颜色
      */
     public void addStateAndColor(int state, int color) {
         this.state = state;
         this.color = color;
         colorMap.put(state, color);
     }

     /**
      * 获取状态.
      *
      * @return state
      */
     public int getState() {
         return state;
     }

     /**
      * 获取颜色.
      *
      * @return color
      */
     public int getColor() {
         return color;
     }
 }
